// https://leetcode.cn/problems/palindrome-linked-list/
// Created by ade on 2022/7/25.
//
#include <iostream>
#include <vector>


using namespace std;

class Solution {
public:
    // 常规方法
    bool isPalindrome(ListNode* head) {
        vector<int> res = {};
        while(head){
            res.push_back(head->val);
            head = head->next;
        }
        if(res.size() == 1) return true;
        int left = 0, right = res.size() - 1;
        while(left < right){
            if(res[left] != res[right]) return false;
            left++;right--;
        }
        return true;
    }

};
